﻿using yiCommerce.Controllers;
using yiCommerce.Core;
using yiCommerce.Core.Domain.Customers;
using yiCommerce.Models.Fans;
using yiCommerce.Service.Pictures;

namespace yiCommerce.Mapper
{
    public class FansMapper
    {
        public static FanListItemModel ToFanList(Customer customer)
        {
            var pictureService = EngineContext.Current.Resolve<IPictureService>();

            var item = new FanListItemModel()
                {
                    FanLogo =
                        customer.CustomerLogo != null
                            ? pictureService.GetPictureUrl(customer.CustomerLogo.PictureId, 50, true)
                            : null,
                    FanName = customer.Username
                };
            return item;
        }
    }
}